package com.aipolice.service;

import com.aipolice.dao.ConreportDAO;
import com.aipolice.pojo.Connews;
import com.aipolice.pojo.Conreport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
public class ConreportService {

    @Autowired
    ConreportDAO conreportDAO;

    public List<Conreport> list() {
        return conreportDAO.findAll();
    }

    public void delete(int id){
//        真删除
        conreportDAO.deleteById(id);
//        软删除
//        Connews connews = connewsDAO.findById(id).get();
//        user.setDel(1);
//        connewsDAO.save(user);
    }


    public void add(Conreport connews){
        conreportDAO.save(connews);
    }

    public Conreport find(int id){
        Optional<Conreport> conreport = conreportDAO.findById(id);
        return conreport.get();
    }
}
